package com.pengshiyu.dao.impl;

import com.pengshiyu.dao.UserDao;
import com.pengshiyu.vo.User;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository("userDao")
public class UserDaoImpl extends SqlSessionDaoSupport implements UserDao {
    @Autowired
    @Override
    public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
        super.setSqlSessionFactory(sqlSessionFactory);
    }

    public List<User> list() {
        return getSqlSession().selectList("com.pengshiyu.vo.user.mapper.selectList");
    }

    public User detail(int id) {
        return getSqlSession().selectOne("com.pengshiyu.vo.user.mapper.selectOne", id);
    }

    public int delete(int id) {
        return getSqlSession().delete("com.pengshiyu.vo.user.mapper.delete", id);
    }

    public int update(User user) {
        return getSqlSession().update("com.pengshiyu.vo.user.mapper.update", user);
    }

    public int insert(User user) {
        return getSqlSession().insert("com.pengshiyu.vo.user.mapper.insert", user);
    }
}
